import Taro, { Component } from '@tarojs/taro'
import {Text, View} from '@tarojs/components'
import { connect } from '@tarojs/redux'
import { AtList, AtListItem, AtCalendar } from 'taro-ui'
import {getPersonAttendList} from './service'
import './index.scss'
import moment from 'moment'


@connect(({ counter }) => ({
  counter
}))
export default class attendance extends Component {

  config = {
    navigationBarTitleText: '考勤查询'
  };

  constructor (props) {
    super(props);
    this.state = {
      userInfo: props.counter,
      values: [{value: '2020/10/22'},{value: '2020/11/22'}],
    }
  }

  componentWillMount () { }

  componentDidMount () {
    const {userInfo} = this.state;
    console.log(this.props.counter)
    /*const { oid } = getCurrentInstance().router.params;
    Taro.showLoading({ title: '加载中' });*/
    let queryData = {
      code: userInfo.usercode,
      name: userInfo.name,
      startDate: moment('2020-09-01').startOf('month'),
      endDate: moment().endOf('month')
    };
    getPersonAttendList(queryData).then(res => {
      console.log(res)
    })
  }

  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }

  turnToReplaceCard() {
    Taro.navigateTo({
      url: '/pages/attendance/replaceCard/index'
    })
  }

  render () {
    return (
      <View>
        <AtCalendar className='padding main-bg' marks={ [ { value: '2020/11/11' } ] } />
        <View className='list main-bg'>
          <View className='item'>
            <View className='content'>
              <View className='title'>上班卡</View>
              <View className='status-success'>正常</View>
            </View>
            <View>
              <View className='content'>
                <View className='title'>08 : 06</View>
                <View className='operate' onClick={this.turnToReplaceCard}>申请补卡</View>
              </View>
            </View>
          </View>
        </View>
      </View>
    )
  }
}
